package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.SysUserRoleService;
import com.atguigu.spzx.model.common.Result;
import com.atguigu.spzx.model.entity.sys.SysRole;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * title:
 * author: zgl
 * date: 2023/12/30
 * description：
 */
@RestController
@RequestMapping("/admin/system/userRole")
@Tag(name = "用户角色管理模块")
public class SysUserRoleController {
    @Autowired
    private SysUserRoleService sysUserRoleService;

    @GetMapping("/AssignRoles/{id}")
    @Operation(summary = "id查询存在角色接口")
    public Result getAssignRoles(@PathVariable Long id) {
        List<SysRole> list = sysUserRoleService.getAssignRoles(id);
        return Result.ok(list);
    }

    @PutMapping("/updateAssignRoles/{userId}")
    @Operation(summary = "id添加角色接口")
    public Result assignRoles(@PathVariable Long userId,
    @RequestBody List<Long> roleIds) {
        sysUserRoleService.updateAssignRoles(userId,roleIds);
        return Result.ok();
    }
}
